package qianzhui;

public class Class303 {

     class  NumArray{
       int[]  preSum;
         public NumArray(int[] nums) {
             preSum = new int[nums.length + 1];
             preSum[0] = 0;
             for (int i = 1; i <= nums.length ; i++) {
                 preSum[i]=preSum[i-1]+nums[i-1];
             }
         }

         /* 查询闭区间 [left, right] 的累加和 */
         public int sumRange(int left, int right) {

             return  preSum[right+1]-preSum[left];
         }
    }

}
